const http = require('http')
const url = require('url')
const server = http.createServer((sreq, sres) => {
  let rq_apart = url.parse(sreq.url)
  let config = {
    host: 'www.baidu.com',
    port: 80,
    pathname: rq_apart.pathname,
    headers: rq_apart.headers
  }
  let creq = http.get(config, (cres) => {
    cres.pipe(sres)
  })
  sreq.pipe(creq)
}).listen(7777, 'localhost')